home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BCI NET
/
BCI NET Dec 94.iso
/
archives
/
telecomm
/
bbs
/
axshsupp.lha
/
AXsh-DateTime10.lha
/
DateTime.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-03-17
|
2KB
|
96 lines
;/* DateTime - a date and time shower especially for AXsh and other stdio
; envinroments. (C) 1993 Osku Sneits / FTeam Labs. You may,
; however, compile this for your own use on AXsh envinroment.
; get_time() (C) by Digital Design.
;
; you can reach me via InterNet hsneits@nyx.cs.du.edu
;
; p.s. instructions: works just like top in AXsh :-)
lc -v -b -r DateTime.c
blink root lib:c.o+DateTime.o to DateTime lib lib:lc.lib+lib:amiga.lib sc sd nd
quit
17-Mar-93 First release. Nothing better to to, so this might
be the first and the last...
****************************************************************************/
#include <exec/types.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <stdio.h>
char *vers="$VER: version 1.0"; /* just a funny way to make CLI command
version DateTime to show version... */
void get_time(char *);
void _main()
{
char dati[30];
BPTR ifp,ofp;
char buf[1];
ifp = Input();
ofp = Output();
for (;;)
{
get_time(dati);
Write(ofp," ",1);
Write(ofp,dati,strlen(dati));
Delay(2);
if (WaitForChar(ifp,1000000))
{
Read(ifp,buf,1);
break;
}
}
}
void get_time(char *a) /* e.g. Sunday 16-Feb-92 18:31:47 */
{ register int year=1978,day=1,month=1,i;
char wdays[7][10]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"},
months[12][4]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
unsigned int hours=0,minutes=0,seconds=0,wday=0,pos1,pos2,
dpm[12]={31,28,31,30,31,30,31,31,30,31,30,31};
struct DateStamp v;
DateStamp(&v);
wday=(day=v.ds_Days)%7;
while(day>=(i=365+((year%4)==0 && (year%100))))
{ day-=i;
++year;
}
while(day>=(i=dpm[month-1]+((year%4)==0 && (year%100) && month==2)))
{ day-=i;
month++;
}
day++;
year=year%100; /* use only tens and ones */
hours=v.ds_Minute/60;
minutes=v.ds_Minute%60;
seconds=v.ds_Tick/TICKS_PER_SECOND;
sprintf(a,"%s xx-%s-xx xx:xx:xx",wdays[wday],months[month-1]);
pos1=strlen(wdays[wday])+1;
pos2=pos1+strlen(months[month-1])+4;
a[pos1]=day/10+'0';
a[pos1+1]=day%10+'0';
a[pos2]=year/10+'0';
a[pos2+1]=year%10+'0';
a[pos2+3]=hours/10+'0';
a[pos2+4]=hours%10+'0';
a[pos2+6]=minutes/10+'0';
a[pos2+7]=minutes%10+'0';
a[pos2+9]=seconds/10+'0';
a[pos2+10]=seconds%10+'0';
a[pos2+11]=' ';
a[pos2+12]='\r';
}